x86/vlapic: fix two flaws in emulating MSR_IA32_APICBASE
authorChao Gao <chao.gao@intel.com>
Tue, 6 Jun 2017 12:34:30 +0000 (14:34 +0200)
committerJan Beulich <jbeulich@suse.com>
Tue, 6 Jun 2017 12:34:30 +0000 (14:34 +0200)
commit4f35cb80e8813053d1cec9dc1654ceb6dd7575a0
treee8ab927735acd2bb359114bec18d821f2c271e30
parent08d3fff66ef74f7ad4c71dd0a19bf528e70ed22e
x86/vlapic: fix two flaws in emulating MSR_IA32_APICBASE

According to SDM Chapter ADVANCED PROGRAMMABLE INTERRUPT CONTROLLER (APIC)
-> Extended XAPIC (x2APIC) -> x2APIC State Transitions, The existing code to
handle guest's writing MSR_IA32_APICBASE has two flaws:
1. Transition from x2APIC Mode to Disabled Mode is allowed but wrongly
disabled currently. Fix it by removing the related check.
2. Transition from x2APIC Mode to xAPIC Mode is illegal but wrongly allowed
currently. Considering changing ENABLE bit of the MSR has been handled,
it can be fixed by only allowing transition from xAPIC Mode to x2APIC Mode
(the other two transitions: from x2APIC mode to xAPIC Mode, from disabled mode
to invalid state (EN=0, EXTD=1) are disabled).

Signed-off-by: Chao Gao <chao.gao@intel.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
xen/arch/x86/hvm/vlapic.c
xen/include/asm-x86/hvm/vlapic.h